home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Dev
/
Obrn-A_1.6_lib.lha
/
oberon-a
/
source3.lha
/
source
/
3rdParty
/
ARP.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
59KB
|
1,449 lines
(*************************************************************************
$RCSfile: ARP.mod $
Description: Interface to arp.library
Created by: fjc (Frank Copeland)
$Revision: 2.11 $
$Author: fjc $
$Date: 1995/06/04 23:11:42 $
Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Library.
See Oberon-A.doc for conditions of use and distribution.
*************************************************************************)
<* STANDARD- *>
MODULE [2] ARP;
(*
************************************************************************
* *
* 5/3/89 ARPbase.h by MKSoft from ARPbase.i by SDB *
* *
************************************************************************
* *
* AmigaDOS Resource Project -- Library Include File *
* for Lattice C 5.x or Manx C 5.x *
* *
************************************************************************
* *
* Copyright (c) 1987/1988/1989 by Scott Ballantyne *
* *
* The arp.library, and related code and files may be freely used *
* by supporters of ARP. Modules in the arp.library may not be *
* extracted for use in independent code, but you are welcome to *
* provide the arp.library with your work and call on it freely. *
* *
* You are equally welcome to add new functions, improve the ones *
* within, or suggest additions. *
* *
* BCPL programs are not welcome to call on the arp.library. *
* The welcome mat is out to all others. *
* *
************************************************************************
* *
* N O T E ! You MUST! have IoErr() defined as LONG to use LastTracker *
* If your compiler has other defines for this, you may wish *
* to remove the prototype for IoErr() from this file. *
* *
************************************************************************
*)
(*
************************************************************************
* First we need to include the Amiga Standard Include files... *
************************************************************************
*)
IMPORT
SYS := SYSTEM, Kernel,
e := Exec, d := Dos, g := Graphics, i := Intuition, s := Sets;
(* All pointers are declared first for convenience *)
TYPE
ArpBasePtr * = POINTER TO ArpBase;
EnvBasePtr * = POINTER TO EnvBase;
FileRequesterPtr * = POINTER TO FileRequester;
AnchorPathPtr * = POINTER TO AnchorPath;
AChainPtr * = POINTER TO AChain;
DirectoryEntryPtr * = POINTER TO DirectoryEntry;
TrackedResourcePtr * = POINTER TO TrackedResource;
DefaultTrackerPtr * = POINTER TO DefaultTracker;
ResListPtr * = POINTER TO ResList;
ZombieMsgPtr * = POINTER TO ZombieMsg;
ProcessControlBlockPtr * = POINTER TO ProcessControlBlock;
NewShellPtr * = POINTER TO NewShell;
ResidentProgramNodePtr * = POINTER TO ResidentProgramNode;
ResidentProgramTagPtr * = POINTER TO ResidentProgramTag;
ProcessMemoryPtr * = POINTER TO ProcessMemory;
DateTimePtr * = POINTER TO DateTime;
CONST
(*
************************************************************************
* Standard definitions for arp library information *
************************************************************************
*)
arpName * = "arp.library"; (* Name of library... *)
arpVersion * = 39; (* Current version... *)
TYPE
(*
************************************************************************
* The current ARP library node... *
************************************************************************
*)
ArpBase * = RECORD (e.LibraryBase)
libNode * : e.Library; (* Standard library node *)
dosRootNode * : d.RootNodePtr; (* Copy of dlRoot *)
abFlags * : s.SET8; (* See bitdefs below *)
escChar * : CHAR; (* Character to be used for escaping *)
arpReserved1 * : LONGINT; (* ArpLib's use only!! *)
envBase * : e.LibraryPtr; (* Dummy library for MANX compatibility*)
dosBase * : d.DosLibraryPtr;(* Cached DosBase *)
gfxBase * : g.GfxBasePtr; (* Cached GfxBase *)
intuiBase * : i.IntuitionBasePtr;(* Cached IntuitionBase *)
resLists * : e.MinList; (* Resource trackers *)
residentPrgList * : ResidentProgramNodePtr; (* Resident Programs. *)
resPrgProtection * : e.SignalSemaphore; (* protection for above *)
segList * : e.BPTR; (* Pointer to loaded libcode (a BPTR). *)
END; (* ArpBase *)
TYPE
(*
***********************************"*"**********************************
* The following is here *ONLY* for information and for *
* compatibility with MANX. DO NOT use in new code! *
************************************************************************
*)
EnvBase * = RECORD
libNode * : e.Library; (* Standard library node for linkage *)
envSpace * : e.ADDRESS; (* Access only when Forbidden! *)
envSize * : e.ULONG; (* Total allocated mem for EnvSpace *)
arpBase * : ArpBasePtr; (* Added in V32 for Resource Tracking *)
END; (* EnvBase *)
CONST
(*
************************************************************************
* These are used in release 33.4 but not by the library code. *
* Instead, individual programs check for these flags. *
************************************************************************
*)
arpWildWorld * = 0; (* Mixed BCPL/Normal wildcards. *)
arpWildBCPL * = 1; (* Pure BCPL wildcards. *)
CONST
(*
************************************************************************
* The alert object is what you use if you really must return an alert *
* to the user. You would normally OR this with another alert number *
* from the alerts.h file. Generally, should be NON deadend alerts. *
* *
* For example, if you can't open ArpLibrary: *
* Alert( (AgOpenLib|AoArpLib), 0L); *
************************************************************************
*)
aoArpLib * = 00008036H; (* Alert object *)
CONST
(*
************************************************************************
* Alerts that arp.library may return... *
************************************************************************
*)
anArpLib * = 03600000H; (* Alert number *)
anArpNoMem * = 03610000H; (* No more memory *)
anArpInputMem * = 03610002H; (* No memory for input buffer *)
anArpNoMakeEnv * = 83610003H; (* No memory to make EnvLib *)
anArpNoDOS * = 83630001H; (* Can't open dos.library *)
anArpNoGfx * = 83630002H; (* Can't open graphics.library *)
anArpNoIntuit * = 83630003H; (* Can't open intuition *)
anBadPackBlues * = 83640000H; (* Bad packet returned to SendPacket() *)
anZombie * = 83600003H; (* Zombie roaming around system *)
anArpScattered * = 83600002H; (* Scatter loading not allowed for arp *)
CONST
(*
************************************************************************
* Return codes you can get from calling ARP Assign()... *
************************************************************************
*)
assignOK * = 0; (* Everything is cool and groovey *)
assignNODEV * = 1; (* "Physical" is not valid for assignment *)
assignFATAL * = 2; (* Something really icky happened *)
assignCANCEL * = 3; (* Tried to cancel something but it won't cancel *)
CONST
(*
************************************************************************
* Size of buffer you need if you are going to call ReadLine() *
************************************************************************
*)
maxInputBuf * = 256;
TYPE
(*
************************************************************************
* The ARP file requester data structure... *
************************************************************************
*)
FileRequester * = RECORD
hail * : e.ADDRESS; (* Hailing text *)
file * : e.ADDRESS; (* Filename array (FCHARS + 1) *)
dir * : e.ADDRESS; (* Directory array (DSIZE + 1) *)
window * : i.WindowPtr; (* Window requesting or NULL *)
funcFlags * : s.SET8; (* Set bitdef's below *)
flags2 * : s.SET8; (* New flags... *)
function * : PROCEDURE(); (* Your function, see bitdef's *)
leftEdge * : INTEGER; (* To be used later... *)
topEdge * : INTEGER;
END; (* FileRequester *)
CONST
(*
************************************************************************
* The following are the defines for frFuncFlags. These bits tell *
* FileRequest() what your frUserFunc is expecting, and what *
* FileRequest() should call it for. *
* *
* You are called like so: *
* frFunction(Mask, Object) *
* e.ULONG Mask; *
* e.APTR *Object; *
* *
* The Mask is a copy of the flag value that caused FileRequest() to *
* call your function. You can use this to determine what action you *
* need to perform, and exactly what Object is, so you know what to do *
* and what to return. *
************************************************************************
*)
doWildFunc * = 7; (* Call me with a FIB and a name, ZERO return accepts. *)
doMsgFunc * = 6; (* You get all IDCMP messages not for FileRequest() *)
doColor * = 5; (* Set this bit for that new and different look *)
newIDCMP * = 4; (* Force a new IDCMP (only if frWindow != NULL) *)
newWindFunc * = 3; (* You get to modify the newwindow structure. *)
addGadFunc * = 2; (* You get to add gadgets. *)
gEventFunc * = 1; (* Function to call if one of your gadgets is selected. *)
listFunc * = 0; (* Not implemented yet. *)
CONST
(*
************************************************************************
* The FR2 bits are for frFlags2 in the file requester structure *
************************************************************************
*)
longPath * = 0; (* Specify the frDir buffer is 256 bytes long *)
CONST
(*
************************************************************************
* The sizes of the different buffers... *
************************************************************************
*)
fChars * = 32; (* Filename size *)
dSize * = 33; (* Directory name size if not FR2LongPath *)
longDSize * = 254; (* If FR2LongPath is set, use longDSIZE *)
longFSize * = 126; (* For compatibility with ARPbase.i *)
firstGadget * = 7680H; (* User gadgetID's must be less than this value *)
TYPE
(*
************************************************************************
* Structure expected by FindFirst()/FindNext() *
* *
* You need to allocate this structure and initialize it as follows: *
* *
* Set apBreakBits to the signal bits (CDEF) that you want to take a *
* break on, or NULL, if you don't want to convenience the user. *
* *
* if you want to have the FULL PATH NAME of the files you found, *
* allocate a buffer at the END of this structure, and put the size of *
* it into apStrLen. If you don't want the full path name, make sure *
* you set apStrLen to zero. In this case, the name of the file, and *
* stats are available in the apInfo, as per usual. *
* *
* Then call FindFirst() and then afterwards, FindNext() with this *
* structure. You should check the return value each time (see below) *
* and take the appropriate action, ultimately calling *
* FreeAnchorChain() when there are no more files and you are done. *
* You can tell when you are done by checking for the normal AmigaDOS *
* return code errorNoMoreENTRIES. *
* *
* You will also have to check the DirEntryType variable in the apInfo *
* structure to determine what exactly you have received. *
************************************************************************
*)
AnchorPath * = RECORD
base * : AChainPtr; (* Pointer to first anchor *)
last * : AChainPtr; (* Pointer to last anchor *)
breakBits * : s.SET32; (* Bits to break on *)
foundBreak * : s.SET32; (* Bits we broke on. Also returns ERROR_BREAK *)
flags * : s.SET8; (* New use for the extra word... *)
reserved * : SYS.BYTE; (* To fill it out... *)
strLen * : INTEGER; (* This is what used to be apLength *)
info * : d.FileInfoBlock;
(*buf * : ARRAY OF SYS.BYTE; (* Allocate a buffer here, if desired *)*)
END; (* AnchorPath *)
CONST
(*
************************************************************************
* Bit definitions for the new apFlags... *
************************************************************************
*)
doWild * = 0; (* User option ALL *)
itsWild * = 1; (* Set by FindFirst, used by FindNext *)
doDir * = 2; (* Bit is SET if a DIR node should be entered *)
(* Application can RESET this bit po AVOID *)
(* entering a dir. *)
didDir * = 3; (* Bit is set for an "expired" dir node *)
noMemErr * = 4; (* Set if there was not enough memory *)
doDot * = 5; (* If set, '.' (DOT) will convert to CurrentDir *)
TYPE
(*
************************************************************************
* Structure used by the pattern matching functions, no need to obtain, *
* diddle or allocate this yourself. *
* *
* Note: If you did, you will now break as it has changed... *
************************************************************************
*)
AChain * = RECORD
child * : AChainPtr;
parent * : AChainPtr;
lock * : d.FileLockPtr;
info * : d.FileInfoBlockPtr;
flags * : s.SET8;
string * : ARRAY 1 OF CHAR; (* Just as is .i file *)
END; (* AChain *) (* ??? Don't use this! *)
CONST
patternBit * = 0;
examinedBit * = 1;
completed * = 2;
allBit * = 3;
CONST
(*
************************************************************************
* Constants used by wildcard routines *
* *
* These are the pre-parsed tokens referred to by pattern match. It *
* is not necessary for you to do anything about these, FindFirst() *
* FindNext() handle all these for you. *
************************************************************************
*)
any * = 80X; (* Token for '*' | '#?' *)
single * = 81X; (* Token for '?' *)
CONST
(*
************************************************************************
* No need to muck with these as they may change... *
************************************************************************
*)
orStart * = 82X; (* Token for '(' *)
orNext * = 83X; (* Token for '|' *)
OrEnd * = 84X; (* Token for ')' *)
not * = 85X; (* Token for '~' *)
notClass * = 87X; (* Token for '^' *)
class * = 88X; (* Token for '[]' *)
repBeg * = 89X; (* Token for '[' *)
repEnd * = 8AX; (* Token for ']' *)
TYPE
(*
************************************************************************
* Structure used by AddDANode(), AddDADevs(), FreeDAList(). *
* *
* This structure is used to create lists of names, which normally *
* are devices, assigns, volumes, files, or directories. *
************************************************************************
*)
DirectoryEntry * = RECORD
next * : DirectoryEntryPtr; (* Next in list *)
type * : SHORTINT; (* dlxmumble *)
flags * : s.SET8; (* For future expansion, DO NOT USE! *)
name * : ARRAY 256 OF CHAR; (* The name of the thing found *)
END; (* DirectoryEntry *)
CONST
(*
************************************************************************
* Defines you use to get a list of the devices you want to look at. *
* For example, to get a list of all directories and volumes, do: *
* *
* AddDADevs( mydalist, (DlfDIRS | dlfVOLUMES) ) *
* *
* After this, you can examine the detype field of the elements added *
* to your list (if any) to discover specifics about the objects added. *
* *
* Note that if you want only devices which are also disks, you must *
* (DlfDEVICES | dlfDISKONLY). *
************************************************************************
*)
devices * = 0; (* Return devices *)
diskOnly * = 1; (* Modifier for above: Return disk devices only *)
volumes * = 2; (* Return volumes only *)
dirs * = 3; (* Return assigned devices only *)
CONST
(*
************************************************************************
* Legal deType values, check for these after a call to AddDADevs(), *
* or use on your own as the ID values in AddDANode(). *
************************************************************************
*)
file * = 0; (* AddDADevs() can't determine this *)
dir * = 8; (* AddDADevs() can't determine this *)
device * = 16H; (* It's a resident device *)
volume * = 24H; (* Device is a volume *)
unmounted * = 32H; (* Device is not resident *)
assign * = 40H; (* Device is a logical assignment *)
(*
************************************************************************
* Resource Tracking stuff... *
************************************************************************
* *
* There are a few things in arp.library that are only directly *
* acessable from assembler. The glue routines provided by us for *
* all 'C' compilers use the following conventions to make these *
* available to C programs. The glue for other language's should use *
* as similar a mechanism as possible, so that no matter what language *
* or compiler we speak, when talk about arp, we will know what the *
* other guy is saying. *
* *
* Here are the cases: *
* *
* Tracker calls... *
* These calls return the Tracker pointer as a secondary *
* result in the register A1. For C, there is no clean *
* way to return more than one result so the tracker *
* pointer is returned in IoErr(). For ease of use, *
* there is a define that typecasts IoErr() to the correct *
* pointer type. This is called LastTracker and should *
* be source compatible with the earlier method of storing *
* the secondary result. *
* *
* GetTracker() - *
* Syntax is a bit different for C than the assembly call *
* The C syntax is GetTracker(ID). The binding routines *
* will store the ID into the tracker on return. Also, *
* in an effort to remain consistant, the tracker will *
* also be stored in LastTracker. *
* *
* In cases where you have allocated a tracker before you have obtained *
* a resource (usually the most efficient method), and the resource has *
* not been obtained, you will need to clear the tracker id. The macro *
* clearID() has been provided for that purpose. It expects a pointer *
* to a DefaultTracker sort of struct. *
************************************************************************
#define CLEAR_ID(t) ((SHORT * ) t)[-1]* =NULL
************************************************************************
* You MUST prototype IoErr() to prevent the possible error in defining *
* IoErr() and thus causing LastTracker to give you trash... *
* *
* N O T E ! You MUST! have IoErr() defined as LONG to use LastTracker *
* If your compiler has other defines for this, you may wish *
* to remove the prototype for IoErr(). *
************************************************************************
#define LastTracker ((struct DefaultTracker * )IoErr())
*)
TYPE
(*
************************************************************************
* The rlFirstItem list (ResList) is a list of TrackedResource (below) *
* It is very important that nothing in this list depend on the task *
* existing at resource freeing time (i.e., RemTask(0L) type stuff, *
* DeletePort() and the rest). *
* *
* The tracking functions return a struct Tracker *Tracker to you, this *
* is a pointer to whatever follows the trID variable. *
* The default case is reflected below, and you get it if you call *
* GetTracker() ( see DefaultTracker below). *
* *
* NOTE: The two user variables mentioned in an earlier version don't *
* exist, and never did. Sorry about that (SDB). *
* *
* However, you can still use ArpAlloc() to allocate your own tracking *
* nodes and they can be any size or shape you like, as long as the *
* base structure is preserved. They will be freed automagically just *
* like the default trackers. *
************************************************************************
*)
TrackedResource * = RECORD
node * : e.MinNode; (* Double linked pointer *)
flags * : s.SET8; (* Don't touch *)
lock * : SYS.BYTE; (* Don't touch, for Get/FreeAccess() *)
id * : INTEGER; (* Item's ID *)
(*
************************************************************************
* The struct DefaultTracker *Tracker portion of the structure. *
* The stuff below this point can conceivably vary, depending *
* on user needs, etc. This reflects the default. *
************************************************************************
*)
object * : e.ADDRESS;
extra * : e.ADDRESS;
END; (* TrackedResource *)
TYPE
(*
************************************************************************
* You get a pointer to a struct of the following type when you call *
* GetTracker(). You can change this, and use ArpAlloc() instead of *
* GetTracker() to do tracking. Of course, you have to take a wee bit *
* more responsibility if you do, as well as if you use trakGeneric *
* stuff. *
* *
* trakGeneric folks need to set up a task function to be called when *
* an item is freed. Some care is required to set this up properly. *
* *
* Some special cases are indicated by the unions below, for *
* trakWindow, if you have more than one window opened, and don't *
* want the IDCMP closed particularly, you need to set a ptr to the *
* other window in dtWindow2. See CloseWindowSafely() for more info. *
* If only one window, set this to NULL. *
************************************************************************
*)
DefaultTracker * = RECORD
object * : e.ADDRESS;
extra * : e.ADDRESS;
END; (* DefaultTracker *)
CONST
(*
************************************************************************
* Items the tracker knows what to do about *
************************************************************************
*)
aAMem * = 0; (* Default (ArpAlloc) element *)
lock * = 1; (* File lock *)
trFile * = 2; (* Opened file *)
window * = 3; (* Window -- see docs *)
screen * = 4; (* Screen *)
library * = 5; (* Opened library *)
dAMem * = 6; (* Pointer to DosAllocMem block *)
memNode * = 7; (* AllocEntry() node *)
segList * = 8; (* Program segment *)
resList * = 9; (* ARP (nested) ResList *)
mem * = 10; (* Memory ptr/length *)
generic * = 11; (* Generic Element, your choice *)
dAList * = 12; (* DAlist ( aka file request ) *)
anchor * = 13; (* Anchor chain (pattern matching) *)
fReq * = 14; (* FileRequest struct *)
font * = 15; (* GfxBase CloseFont() *)
max * = 15; (* Poof, anything higher is tossed *)
unlink * = 7; (* Free node bit *)
reloc * = 6; (* This may be relocated (not used yet) *)
moved * = 5; (* Item moved *)
TYPE
(*
************************************************************************
* Note: ResList MUST be a DosAllocMem'ed list!, this is done for *
* you when you call CreateTaskResList(), typically, you won't need *
* to access/allocate this structure. *
************************************************************************
*)
ResList * = RECORD
node * : e.MinNode; (* Used by arplib to link reslists *)
taskID * : e.TaskPtr; (* Owner of this list *)
firstItem * : e.MinList; (* List of Tracked Resources *)
link * : ResListPtr; (* SyncRun's use - hide list here *)
END; (* ResList *)
CONST
(*
************************************************************************
* Returns from CompareLock() *
************************************************************************
*)
equal * = 0; (* The two locks refer to the same object *)
clVolume * = 1; (* Locks are on the same volume *)
difVol1 * = 2; (* Locks are on different volumes *)
difVol2 * = 3; (* Locks are on different volumes *)
TYPE
(*
************************************************************************
* ASyncRun() stuff... *
************************************************************************
* Message sent back on your request by an exiting process. *
* You request this by putting the address of your message in *
* pcbLastGasp, and initializing the ReplyPort variable of your *
* ZombieMsg to the port you wish the message posted to. *
************************************************************************
*)
ZombieMsg * = RECORD
execMessage * : e.Message;
taskNum * : e.ULONG; (* Task ID *)
returnCode * : LONGINT; (* Process's return code *)
result2 * : e.ULONG; (* System return code *)
exitTime * : d.Date; (* Date stamp at time of exit *)
userInfo * : e.ULONG; (* For whatever you wish *)
END; (* ZombieMsg *)
TYPE
(*
************************************************************************
* Structure required by ASyncRun() -- see docs for more info. *
************************************************************************
*)
ProcessControlBlock * = RECORD
stackSize * : e.ULONG; (* Stacksize for new process *)
pri * : SHORTINT; (* Priority of new task *)
control * : s.SET8; (* Control bits, see defines below *)
trapCode * : e.ADDRESS; (* Optional Trap Code *)
input * : e.BPTR;
output * : e.BPTR; (* Optional stdin, stdout *)
console * : LONGINT;
(* console is a union of:
splatFile * : e.BPTR; (* File to use for Open("*") *)
conName * : e.LSTRPTR; (* CON: filename *)
*)
loadedCode * : e.ADDRESS; (* If not null, will not load/unload code *)
lastGasp * : ZombieMsgPtr; (* ReplyMsg() to be filled in by exit *)
wbProcess * : e.MsgPort; (* Valid only when prNOCLI *)
END; (* ProcessControlBlock *)
CONST
(*
************************************************************************
* Formerly needed to pass NULLCMD to a child. No longer needed. *
* It is being kept here for compatibility only... *
************************************************************************
*)
NoCmd * = "\n";
CONST
(*
************************************************************************
* The following control bits determine what ASyncRun() does on *
* Abnormal Exits and on background process termination. *
************************************************************************
*)
saveIO * = 0; (* Don't free/check file handles on exit *)
closeSplat * = 1; (* Close Splat file, must request explicitly *)
noCLI * = 2; (* Don't create a CLI process *)
(*interactive * = 3; This is now obsolete... *)
code * = 4; (* Dangerous yet enticing *)
stdio * = 5; (* Do the stdio thing, splat * = CON:Filename *)
CONST
(*
************************************************************************
* Error returns from SyncRun() and ASyncRun() *
************************************************************************
*)
noFile * = -1; (* Could not LoadSeg() the file *)
noMem * = -2; (* No memory for something *)
(*noCLI = -3; This is now obsolete *)
noSlot * = -4; (* No room in TaskArray *)
noInput * = -5; (* Could not open input file *)
noOutput * = -6; (* Could not get output file *)
(*noLock = -7; This is now obsolete *)
(*argErr = -8; This is now obsolete *)
(*noBCPL = -9; This is now obsolete *)
(*badLib = -10; This is now obsolete *)
noStdio * = -11; (* Couldn't get stdio handles *)
CONST
(*
************************************************************************
* Added V35 of arp.library *
************************************************************************
*)
wantSMessage * = -12; (* Child wants you to report IoErr() to user *)
(* for SyncRun() only... *)
noShellProc * = -13; (* Can't create a shell/cli process *)
noExec * = -14; (* 'E' bit is clear *)
script * = -15; (* S and E are set, IoErr() contains directory *)
TYPE
(*
************************************************************************
* Version 35 ASyncRun() allows you to create an independent *
* interactive or background Shell/CLi. You need this variant of the *
* pcb structure to do it, and you also have new values for nshControl, *
* see below. *
* *
* Syntax for Interactive shell is: *
* *
* rc=ASyncRun("Optional Window Name","Optional From File",&NewShell); *
* *
* Syntax for a background shell is: *
* *
* rc=ASyncRun("Command line",0L,&NewShell); *
* *
* Same syntax for an Execute style call, but you have to be on drugs *
* if you want to do that. *
************************************************************************
*)
NewShell * = RECORD
stackSize * : e.ULONG; (* stacksize shell will use for children *)
pri * : SHORTINT; (* ignored by interactive shells *)
control * : s.SET8; (* bits/values: see above *)
logMsg * : e.ADDRESS;(* Optional login message, if null, use default *)
input * : e.BPTR; (* ignored by interactive shells, but *)
output * : e.BPTR; (* used by background and execute options. *)
reserved * : ARRAY 5 OF LONGINT;
END; (* NewShell *)
CONST
(*
************************************************************************
* Bit Values for nshControl, you should use them as shown below, or *
* just use the actual values indicated. *
************************************************************************
*)
cli * = 0; (* Do a CLI, not a shell *)
backGround * = 1; (* Background shell *)
execute * = 2; (* Do as EXECUTe... *)
interactive * = 3; (* Run an interactive shell *)
fb * = 7; (* Alt function bit... *)
CONST
(*
************************************************************************
* Common values for shControl which allow you to do usefull *
* and somewhat "standard" things... *
************************************************************************
*)
interactiveShell * = { fb, interactive }; (* Gimme a newshell! *)
interactiveCLI * = { fb, interactive, cli }; (* Gimme that ol newcli! *)
backgroundShell * = { fb, backGround }; (* gimme a background shell *)
executeMe * = { fb, backGround, execute }; (* aptly named, doncha think? *)
CONST
(*
************************************************************************
* Additional IoErr() returns added by ARP... *
************************************************************************
*)
errorBufferOverflow * = 303; (* User or internal buffer overflow *)
errorBreak * = 304; (* A break character was received *)
errorNotExecutable * = 305; (* A file has E bit cleared *)
errorNotCLI * = 400; (* Program/function neeeds to be cli *)
TYPE
(*
************************************************************************
* Resident Program Support *
************************************************************************
* This is the kind of node allocated for you when you AddResidentPrg() *
* a code segment. They are stored as a single linked list with the *
* root in ArpBase. If you absolutely *must* wander through this list *
* instead of using the supplied functions, then you must first obtain *
* the semaphore which protects this list, and then release it *
* afterwards. Do not use Forbid() and Permit() to gain exclusive *
* access! Note that the supplied functions handle this locking *
* protocol for you. *
************************************************************************
*)
ResidentProgramNode * = RECORD
next * : ResidentProgramNodePtr; (* next or NULL *)
usage * : LONGINT; (* Number of current users *)
accessCnt * : e.UWORD; (* Total times used... *)
checkSum * : e.ULONG; (* Checksum of code *)
segment * : e.BPTR; (* Actual segment *)
flags * : s.SET16; (* See definitions below... *)
(*name * : ARRAY OF CHAR; (* Allocated as needed *)*)
END; (* ResidentProgramNode *)
CONST
(*
************************************************************************
* Bit definitions for rpnFlags.... *
************************************************************************
*)
noCheck * = 0; (* Set in rpnFlags for no checksumming... *)
cache * = 1; (* Private usage in v1.3... *)
TYPE
(*
************************************************************************
* If your program starts with this structure, ASyncRun() and SyncRun() *
* will override a users stack request with the value in rptStackSize. *
* Furthermore, if you are actually attached to the resident list, a *
* memory block of size rptDataSize will be allocated for you, and *
* a pointer to this data passed to you in register A4. You may use *
* this block to clone the data segment of programs, thus resulting in *
* one copy of text, but multiple copies of data/bss for each process *
* invocation. If you are resident, your program will start at *
* rptInstruction, otherwise, it will be launched from the initial *
* branch. *
************************************************************************
*)
ResidentProgramTag * = RECORD
nextSeg * : e.BPTR; (* Provided by DOS at LoadSeg time *)
(*
************************************************************************
* The initial branch destination and rptInstruction do not have to be *
* the same. This allows different actions to be taken if you are *
* diskloaded or resident. DataSize memory will be allocated only if *
* you are resident, but StackSize will override all user stack *
* requests. *
************************************************************************
*)
bra * : e.UWORD; (* Short branch to executable *)
magic * : e.UWORD; (* Resident majik value *)
stackSize * : e.ULONG; (* min stack for this process *)
dataSize * : e.ULONG; (* Data size to allocate if resident *)
(* instruction; Start here if resident *)
END; (* ResidentProgramTag *)
TYPE
(*
************************************************************************
* The form of the ARP allocated node in your tasks memlist when *
* launched as a resident program. Note that the data portion of the *
* node will only exist if you have specified a nonzero value for *
* rptDataSize. Note also that this structure is READ ONLY, modify *
* values in this at your own risk. The stack stuff is for tracking, *
* if you need actual addresses or stack size, check the normal places *
* for it in your process/task struct. *
************************************************************************
*)
ProcessMemory * = RECORD
node * : e.Node;
num * : e.UWORD; (* This is 1 if no data, two if data *)
stack * : e.APTR;
stackSize * : e.ULONG;
data * : e.APTR; (* Only here if pmNum == 2 *)
dataSize * : e.ULONG;
END; (* ProcessMemory *)
CONST
(*
************************************************************************
* To find the above on your memlist, search for the following name. *
* We guarantee this will be the only arp.library allocated node on *
* your memlist with this name. *
* i.e. FindName(task->tcbMemEntry, pmemNAME); *
************************************************************************
*)
pMemName * = "ARP_MEM";
residentMagic * = 4AFCH; (* same as rtcMATCHWORD (trapf) *)
TYPE
(*
************************************************************************
* Date String/Data structures *
************************************************************************
*)
DateTime * = RECORD
stamp * : d.Date; (* DOS Datestamp *)
format * : SYS.BYTE; (* controls appearance ot datStrDate *)
flags * : s.SET8; (* See BITDEF's below *)
strDay * : e.ADDRESS; (* day of the week string *)
strDate * : e.ADDRESS; (* date string *)
strTime * : e.ADDRESS; (* time string *)
END; (* DateTime *)
CONST
(*
************************************************************************
* Size of buffer you need for each DateTime strings: *
************************************************************************
*)
lenDatString * = 10;
CONST
(*
************************************************************************
* For datFlags *
************************************************************************
*)
subSt * = 0; (* Substitute "Today" "Tomorrow" where appropriate *)
future * = 1; (* Day of the week is in future *)
CONST
(*
************************************************************************
* For datFormat *
************************************************************************
*)
formatDos * = 0; (* dd-mmm-yy AmigaDOS's own, unique style *)
formatInt * = 1; (* yy-mm-dd International format *)
formatUSA * = 2; (* mm-dd-yy The good'ol'USA. *)
formatCDN * = 3; (* dd-mm-yy Our brothers and sisters to the north *)
formatMAX * = formatCDN; (* Larger than this? Defaults to AmigaDOS *)
(* --- Library Base variable -------------------------------------------- *)
VAR
arp *, base * : ArpBasePtr;
(* --- Library Functions ------------------------------------------------ *)
TYPE
PROC * = PROCEDURE();
(*
************************************************************************
* These duplicate the calls in dos.library *
* Only include if you can use arp.library without dos.library *
************************************************************************
*)
PROCEDURE Open* [base,-30]
( name [1] : ARRAY OF CHAR;
accessMode [2] : LONGINT)
: d.FileHandlePtr;
PROCEDURE Close* [base,-36]
( file [1] : d.FileHandlePtr );
PROCEDURE Read* [base,-42]
( file [1] : d.FileHandlePtr;
VAR buffer [2] : ARRAY OF SYS.BYTE;
length [3] : LONGINT)
: LONGINT;
PROCEDURE Write* [base,-48]
( file [1] : d.FileHandlePtr;
buffer [2] : ARRAY OF SYS.BYTE;
length [3] : LONGINT)
: LONGINT;
PROCEDURE Input* [base,-54] ()
: d.FileHandlePtr;
PROCEDURE Output* [base,-60] ()
: d.FileHandlePtr;
PROCEDURE Seek* [base,-66]
( file [1] : d.FileHandlePtr;
position [2] : LONGINT;
offset [3] : LONGINT)
: LONGINT;
PROCEDURE DeleteFile* [base,-72]
( name [1] : ARRAY OF CHAR )
: BOOLEAN;
PROCEDURE Rename* [base,-78]
( oldName [1] : ARRAY OF CHAR;
newName [2] : ARRAY OF CHAR )
: BOOLEAN;
PROCEDURE Lock* [base,-84]
( name [1] : ARRAY OF CHAR;
type [2] : LONGINT)
: d.FileLockPtr;
PROCEDURE UnLock* [base,-90]
( lock [1] : d.FileLockPtr );
PROCEDURE DupLock* [base,-96]
( lock [1] : d.FileLockPtr )
: d.FileLockPtr;
PROCEDURE Examine* [base,-102]
( lock [1] : d.FileLockPtr;
fileInfoBlock [2] : d.FileInfoBlockPtr )
: BOOLEAN;
PROCEDURE ExNext* [base,-108]
( lock [1] : d.FileLockPtr;
fileInfoBlock [2] : d.FileInfoBlockPtr )
: BOOLEAN;
PROCEDURE Info* [base,-114]
( lock [1] : d.FileLockPtr;
parameterBlock [2] : d.InfoDataPtr )
: BOOLEAN;
PROCEDURE CreateDir* [base,-120]
( name [1] : ARRAY OF CHAR )
: d.FileLockPtr;
PROCEDURE CurrentDir* [base,-126]
( lock [1] : d.FileLockPtr )
: d.FileLockPtr;
PROCEDURE IoErr* [base,-132] ()
: LONGINT;
PROCEDURE CreateProc* [base,-138]
( name [1] : ARRAY OF CHAR;
pri [2] : LONGINT;
segList [3] : e.BPTR;
stackSize [4] : LONGINT)
: e.MsgPortPtr;
PROCEDURE Exit* [base,-144]
( returnCode [1] : LONGINT);
PROCEDURE LoadSeg* [base,-150]
( name [1] : ARRAY OF CHAR )
: e.BPTR;
PROCEDURE UnLoadSeg* [base,-156]
( seglist [1] : e.BPTR );
PROCEDURE DeviceProc* [base,-174]
( name [1] : ARRAY OF CHAR )
: e.MsgPortPtr;
PROCEDURE SetComment* [base,-180]
( name [1] : ARRAY OF CHAR;
comment [2] : ARRAY OF CHAR )
: BOOLEAN;
PROCEDURE SetProtection* [base,-186]
( name [1] : ARRAY OF CHAR;
protect [2] : s.SET32)
: BOOLEAN;
PROCEDURE DateStamp* [base,-192]
( VAR date [1] : d.DateBase );
PROCEDURE Delay* [base,-198]
( timeout [1] : e.ULONG);
PROCEDURE WaitForChar* [base,-204]
( file [1] : d.FileHandlePtr;
timeout [2] : LONGINT)
: BOOLEAN;
PROCEDURE ParentDir* [base,-210]
( lock [1] : d.FileLockPtr )
: d.FileLockPtr;
PROCEDURE IsInteractive* [base,-216]
( file [1] : d.FileHandlePtr )
: BOOLEAN;
PROCEDURE Execute* [base,-222]
( string [1] : ARRAY OF CHAR;
file [2] : d.FileHandlePtr;
file2 [3] : d.FileHandlePtr )
: LONGINT;
(*
************************************************************************
* Now for the stuff that only exists in arp.library... *
************************************************************************
*)
PROCEDURE VPrintf* [base,-228]
( string [8] : ARRAY OF CHAR;
args [9] : ARRAY OF e.ADDRESS )
: LONGINT;
PROCEDURE Printf* [base,-228]
( string [8] : ARRAY OF CHAR;
args [9]..: e.APTR )
: LONGINT;
PROCEDURE VFPrintf* [base,-234]
( file [0] : d.FileHandlePtr;
string [8] : ARRAY OF CHAR;
args [9] : ARRAY OF e.APTR )
: LONGINT;
PROCEDURE FPrintf* [base,-234]
( file [0] : d.FileHandlePtr;
string [8] : ARRAY OF CHAR;
args [9]..: e.APTR )
: LONGINT;
PROCEDURE Puts* [base,-240]
( string [9] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE ReadLine* [base,-246]
( VAR string [8] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE GADS* [base,-252]
( line [8] : ARRAY OF CHAR;
len [0] : LONGINT;
help [9] : e.ADDRESS;
VAR args [10] : ARRAY OF SYS.LONGWORD;
temp [11] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE Atol* [base,-258]
( string [8] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE EscapeString* [base,-264]
( string [8] : ARRAY OF CHAR )
: e.ULONG;
PROCEDURE CheckAbort* [base,-270]
( func [9] : e.PROC )
: LONGINT;
PROCEDURE CheckBreak* [base,-276]
( mask [1] : s.SET32;
func [9] : e.PROC )
: LONGINT;
PROCEDURE Getenv* [base,-282]
( string [8] : ARRAY OF CHAR;
VAR buffer [9] : ARRAY OF CHAR;
size [0] : LONGINT )
: e.ADDRESS;
PROCEDURE Setenv* [base,-288]
( varName [8] : ARRAY OF CHAR;
value [9] : ARRAY OF CHAR )
: BOOLEAN;
PROCEDURE FileRequest* [base,-294]
( VAR fileRequester [8] : FileRequester )
: e.ADDRESS;
PROCEDURE CloseWindowSafely* [base,-300]
( window [8] : i.WindowPtr;
moreWindows [9] : i.WindowPtr );
PROCEDURE CreatePort* [base,-306]
( name [8] : ARRAY OF CHAR;
pri [0] : LONGINT )
: e.MsgPortPtr;
PROCEDURE DeletePort* [base,-312]
( port [9] : e.MsgPortBasePtr );
PROCEDURE SendPacket* [base,-318]
( action [0] : LONGINT;
args [8] : e.ADDRESS;
handler [9] : e.MsgPortBasePtr )
: LONGINT;
PROCEDURE InitStdPacket* [base,-324]
( action [0] : LONGINT;
args [8] : e.ADDRESS;
packet [9] : d.DosPacketPtr;
replyPort [10] : e.MsgPortBasePtr );
PROCEDURE PathName* [base,-330]
( lock [0] : d.FileLockPtr;
VAR buffer [8] : ARRAY OF CHAR;
componentCount [1] : LONGINT )
: e.ULONG;
PROCEDURE Assign* [base,-336]
( logical [8] : ARRAY OF CHAR;
physical [9] : ARRAY OF CHAR )
: e.ULONG;
PROCEDURE DosAllocMem* [base,-342]
( size [0] : LONGINT )
: e.APTR;
PROCEDURE DosFreeMem* [base,-348]
( block [9] : e.APTR );
PROCEDURE BtoCStr* [base,-354]
( VAR cstr [8] : ARRAY OF CHAR;
bstr [0] : d.BSTR;
maxLength [1] : LONGINT )
: e.ULONG;
PROCEDURE CtoBStr* [base,-360]
( cstr [8] : ARRAY OF CHAR;
VAR bstr [0] : d.BSTR;
maxLength [1] : LONGINT )
: e.ULONG;
PROCEDURE GetDevInfo* [base,-366]
( devNode [10] : d.DeviceListPtr )
: d.DeviceListPtr;
PROCEDURE FreeTaskResList* [base,-372] ()
: BOOLEAN;
PROCEDURE ArpExit* [base,-378]
( rc [0] : LONGINT;
fault [2] : LONGINT );
PROCEDURE ArpAlloc* [base,-384]
( size [0] : LONGINT )
: e.ADDRESS;
PROCEDURE ArpAllocMem* [base,-390]
( size [0] : LONGINT;
requirements [1] : s.SET32 )
: e.ADDRESS;
PROCEDURE ArpOpen* [base,-396]
( name [1] : ARRAY OF CHAR;
mode [2] : LONGINT )
: d.FileHandlePtr;
PROCEDURE ArpDupLock* [base,-402]
( lock [1] : d.FileLockPtr )
: d.FileLockPtr;
PROCEDURE ArpLock* [base,-408]
( name [1] : ARRAY OF CHAR;
mode [2] : LONGINT )
: d.FileLockPtr;
PROCEDURE RListAlloc* [base,-414]
( resList [8] : ResListPtr;
size [0] : LONGINT )
: e.ADDRESS;
PROCEDURE FindCLI* [base,-420]
( cliNum [0] : LONGINT )
: e.APTR;
PROCEDURE QSort* [base,-426]
( data [8] : e.APTR;
rSize [0] : LONGINT;
bSize [1] : LONGINT;
comp [9] : e.PROC )
: BOOLEAN;
PROCEDURE PatternMatch* [base,-432]
( pattern [8] : ARRAY OF CHAR;
string [9] : ARRAY OF CHAR )
: BOOLEAN;
PROCEDURE FindFirst* [base,-438]
( pattern [0] : ARRAY OF CHAR;
VAR path [8] : AnchorPath )
: LONGINT;
PROCEDURE FindNext* [base,-444]
( VAR path [8] : AnchorPath )
: LONGINT;
PROCEDURE FreeAnchorChain* [base,-450]
( VAR path [8] : AnchorPath );
PROCEDURE CompareLock* [base,-456]
( lock1 [0] : d.FileLockPtr;
lock2 [1] : d.FileLockPtr )
: e.ULONG;
PROCEDURE FindTaskResList* [base,-462] ()
: ResListPtr;
PROCEDURE CreateTaskResList* [base,-468] ()
: ResListPtr;
PROCEDURE FreeResList* [base,-474]
( freeList [9] : ResListPtr );
PROCEDURE FreeTrackedItem* [base,-480]
( item [9] : DefaultTrackerPtr );
PROCEDURE GetTracker* [base,-486]
( size [9] : LONGINT )
: DefaultTrackerPtr;
PROCEDURE GetAccess* [base,-492]
( tracker [9] : DefaultTrackerPtr )
: e.APTR;
PROCEDURE FreeAccess* [base,-498]
( tracker [9] : DefaultTrackerPtr );
PROCEDURE FreeDAList* [base,-504]
( VAR node [9] : DirectoryEntry );
PROCEDURE AddDANode* [base,-510]
( data [8] : ARRAY OF CHAR;
VAR daList [9] : DirectoryEntry;
length [0] : LONGINT;
id [1] : LONGINT )
: DirectoryEntryPtr;
PROCEDURE AddDADevs* [base,-516]
( VAR daList [8] : DirectoryEntry;
select [0] : s.SET32 )
: e.ULONG;
PROCEDURE Strcmp* [base,-522]
( s1 [8] : ARRAY OF CHAR;
s2 [9] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE Strncmp* [base,-528]
( s1 [8] : ARRAY OF CHAR;
s2 [9] : ARRAY OF CHAR;
length [0] : LONGINT )
: LONGINT;
PROCEDURE ToUpper* [base,-534]
( char [0] : CHAR )
: CHAR;
PROCEDURE SyncRun* [base,-540]
( name [8] : ARRAY OF CHAR;
command [9] : e.ADDRESS;
input [0] : d.FileHandlePtr;
output [1] : d.FileHandlePtr )
: LONGINT;
(*
************************************************************************
* Added V32 of arp.library *
************************************************************************
*)
PROCEDURE ASyncRun* [base,-546]
( name [8] : ARRAY OF CHAR;
command [9] : e.ADDRESS;
VAR pcb [10] : ProcessControlBlock )
: LONGINT;
PROCEDURE SpawnShell* [base,-546]
( name [8] : ARRAY OF CHAR;
command [9] : e.ADDRESS;
VAR shell [10] : NewShell )
: LONGINT;
PROCEDURE LoadPrg* [base,-552]
( name [1] : ARRAY OF CHAR )
: e.BPTR;
PROCEDURE PreParse* [base,-558]
( source [8] : ARRAY OF CHAR;
VAR dest [9] : ARRAY OF CHAR )
: BOOLEAN;
(*
************************************************************************
* Added V33 of arp.library *
************************************************************************
*)
PROCEDURE StamptoStr* [base,-564]
( VAR dateTime [8] : DateTime )
: BOOLEAN;
PROCEDURE StrtoStamp* [base,-570]
( VAR dateTime [8] : DateTime )
: BOOLEAN;
PROCEDURE ObtainResidentPrg* [base,-576]
( name [8] : ARRAY OF CHAR )
: ResidentProgramNodePtr;
PROCEDURE AddResidentPrg* [base,-582]
( segment [1] : e.BPTR;
name [8] : ARRAY OF CHAR )
: ResidentProgramNodePtr;
PROCEDURE RemResidentPrg* [base,-588]
( name [8] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE UnLoadPrg* [base,-594]
( segment [1] : e.BPTR );
PROCEDURE LMult* [base,-600]
( a [0] : LONGINT;
b [1] : LONGINT )
: LONGINT;
PROCEDURE LDiv* [base,-606]
( a [0] : LONGINT;
b [1] : LONGINT )
: LONGINT;
PROCEDURE LMod* [base,-612]
( a [0] : LONGINT;
b [1] : LONGINT )
: LONGINT;
PROCEDURE CheckSumPrg* [base,-618]
( VAR node [0] : ResidentProgramNode )
: e.ULONG;
PROCEDURE TackOn* [base,-624]
( VAR pathname [8] : ARRAY OF CHAR;
filename [9] : ARRAY OF CHAR );
PROCEDURE BaseName* [base,-630]
( name [8] : ARRAY OF CHAR )
: e.ADDRESS;
PROCEDURE ReleaseResidentPrg* [base,-636]
( segment [1] : e.BPTR )
: ResidentProgramNodePtr;
(*
************************************************************************
* Added V36 of arp.library *
************************************************************************
*)
PROCEDURE SPrintf* [base,-642]
( file [0] : e.ADDRESS;
string [8] : ARRAY OF CHAR;
stream [9] : e.ADDRESS )
: LONGINT;
PROCEDURE GetKeywordIndex* [base,-648]
( key [8] : ARRAY OF CHAR;
template [9] : ARRAY OF CHAR )
: LONGINT;
PROCEDURE ArpOpenLibrary* [base,-654]
( name [9] : ARRAY OF CHAR;
version [0] : LONGINT )
: e.LibraryPtr;
PROCEDURE ArpAllocFreq* [base,-660] ()
: FileRequesterPtr;
(* --- Library Base variable -------------------------------------------- *)
<*$LongVars-*>
(*------------------------------------*)
PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
BEGIN (* CloseLib *)
IF base # NIL THEN e.CloseLibrary (base) END
END CloseLib;
BEGIN (* ARP *)
base := SYS.VAL (ArpBasePtr,
e.OpenLibrary (arpName, arpVersion));
IF base = NIL THEN HALT (100) END;
arp := base; Kernel.SetCleanup (CloseLib)
END ARP.